//
//  BaseInfoOneCell.m
//  JinFuThree
//
//  Created by 毛韶谦 on 2018/9/3.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "BaseInfoOneCell.h"
#import "MyInfoModel.h"

@interface BaseInfoOneCell ()

@property (nonatomic, strong) UIImageView *leftImageView;
@property (nonatomic, strong) UIImageView *rightImageView;

@end

@implementation BaseInfoOneCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UILabel *label = [[UILabel alloc] init];
        label.textColor = HexColor(0x999999);
        label.text = @"身份信息";
        label.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).offset(20);
            make.top.mas_equalTo(self.contentView.mas_top).offset(15);
        }];
        
        [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).offset(20);
            make.top.mas_equalTo(self.contentView.mas_top).offset(45);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-15);
            make.right.mas_equalTo(self.rightImageView.mas_left).offset(-20);
        }];
        [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.mas_equalTo(self.leftImageView);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-20);
            make.width.mas_equalTo(self.leftImageView.mas_width);
        }];
        
        UIImageView *leftImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_shuiyin"]];
        [leftImageView setContentMode:UIViewContentModeScaleAspectFit];
        
        [self.contentView addSubview:leftImageView];
        [leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.leftImageView.mas_left).offset(32);
            make.right.mas_equalTo(self.leftImageView.mas_right).offset(-32);
            make.top.mas_equalTo(self.leftImageView.mas_top).offset(20);
            make.bottom.mas_equalTo(self.leftImageView.mas_bottom).offset(-20);
        }];
        
        UIImageView *rightImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_shuiyin"]];
        [rightImageView setContentMode:UIViewContentModeScaleAspectFit];
        
        [self.contentView addSubview:rightImageView];
        [rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.rightImageView.mas_left).offset(32);
            make.right.mas_equalTo(self.rightImageView.mas_right).offset(-32);
            make.top.mas_equalTo(self.rightImageView.mas_top).offset(20);
            make.bottom.mas_equalTo(self.rightImageView.mas_bottom).offset(-20);
        }];
    }
    return self;
}

- (void)updateImageViewInfoModel:(MyInfoBasicsModel *)model {
    
    [self.rightImageView sd_setImageWithURL:[NSURL URLWithString:model.identityCardFrontImg]];
    [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:model.identityCardReverseImg]];
}


- (UIImageView *)leftImageView {
    
    if (!_leftImageView) {
        _leftImageView = [[UIImageView alloc] init];
        [_leftImageView setContentMode:UIViewContentModeScaleAspectFit];
        
        [self.contentView addSubview:_leftImageView];
    }
    return _leftImageView;
}

- (UIImageView *)rightImageView {
    
    if (!_rightImageView) {
        _rightImageView = [[UIImageView alloc] init];
        [_rightImageView setContentMode:UIViewContentModeScaleAspectFit];
        
        [self.contentView addSubview:_rightImageView];
    }
    return _rightImageView;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
